package com.java.mybatis.service.impl;

import com.java.mybatis.dao.OrdergoodsDao;
import com.java.mybatis.entity.Ordergoods;
import com.java.mybatis.service.OrdergoodsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Ordergoods)表服务实现类
 *
 * @author makejava
 * @since 2021-01-15 17:10:28
 */
@Service("ordergoodsService")
public class OrdergoodsServiceImpl implements OrdergoodsService {
    @Resource
    private OrdergoodsDao ordergoodsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param ordergoodsId 主键
     * @return 实例对象
     */
    @Override
    public Ordergoods queryById(Integer ordergoodsId) {
        return this.ordergoodsDao.queryById(ordergoodsId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Ordergoods> queryAllByLimit(int offset, int limit) {
        return this.ordergoodsDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param ordergoods 实例对象
     * @return 实例对象
     */
    @Override
    public Ordergoods insert(Ordergoods ordergoods) {
        this.ordergoodsDao.insert(ordergoods);
        return ordergoods;
    }

    /**
     * 修改数据
     *
     * @param ordergoods 实例对象
     * @return 实例对象
     */
    @Override
    public Ordergoods update(Ordergoods ordergoods) {
        this.ordergoodsDao.update(ordergoods);
        return this.queryById(ordergoods.getOrdergoodsId());
    }

    /**
     * 通过主键删除数据
     *
     * @param ordergoodsId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer ordergoodsId) {
        return this.ordergoodsDao.deleteById(ordergoodsId) > 0;
    }

    @Override
    public List<Ordergoods> selAll() throws Exception {
        return this.ordergoodsDao.selAll();
    }

    @Override
    public Ordergoods selSomeOne(Integer id) throws Exception {
        return this.ordergoodsDao.selSomeOne(id);
    }

    /**
     * 查询所有数据
     * @param page
     * @param pageSize
     * @return
     */
    @Override
    public List<Ordergoods> GetAll(Integer page,Integer pageSize)  {
        return ordergoodsDao.GetAll(page, pageSize);
    }

    /**
     * 查询总行数
     * @return
     * @throws Exception
     */
    @Override
    public Integer ordergoodsCount() throws Exception {
        return this.ordergoodsDao.ordergoodsCount();
    }

    /**
     * 修改定单商品状态
     * @param ordergoodsId
     * @return
     */
    @Override
    public int updateOrdergoodsState(Integer ordergoodsId) {
        return ordergoodsDao.updateOrdergoodsState(ordergoodsId);
    }


    /**
     * 根据orderId查询ordergoods
     * @param orderId
     * @return
     */
    @Override
    public List<Ordergoods> queryByOrderId(Integer orderId){
        return ordergoodsDao.queryByOrderId(orderId);
    }

    /**
     * 模糊查询
     * @param str
     * @return
     * @throws Exception
     */
    @Override
    public List<Ordergoods> selectOrdergoodslike(String str) throws Exception {
        return ordergoodsDao.selectOrdergoodslike(str);
    }

    @Override
    public List<Ordergoods> queryLocation1() {
        return ordergoodsDao.queryLocation1();
    }

    @Override
    public List<Ordergoods> selectGoodsName() {
        return ordergoodsDao.selectGoodsName();
    }

    /**
     * 模糊查询总条数
     * @param str
     * @return
     * @throws Exception
     */
    @Override
    public int selectOrdergoodslikeCount(String str) throws Exception {
        return ordergoodsDao.selectOrdergoodslikeCount(str);
    }

}